package phidgetmotion.gui;

import javax.swing.JLabel;
import javax.swing.JPanel;

import phidgetmotion.classifier.ClassChangeListener;
import phidgetmotion.classifier.Classifier;
import phidgetmotion.classifier.Model;
import phidgetmotion.classifier.ModelChangeListener;

public class TestPanel extends JPanel {
	private static final long serialVersionUID = -8100340478449967492L;
	private final JLabel predictedClass = new JLabel();
	private Classifier classifier;
	
	private ClassChangeListener classChangeListener = new ClassChangeListener() {
		@Override
		public void classChanged(int classId) {
			if(classId==-1) predictedClass.setText("unknown");
			else predictedClass.setText(classifier.getClasses()[classId]);
		}
	};
	
	private ModelChangeListener modelChange = new ModelChangeListener() {
		@Override
		public void modelRemoved() {
			
		}
		
		@Override
		public void modelAdded(Model model) {
			classifier = model;
			classifier.addClassChangeListener(classChangeListener);
		}
	};
	
	public TestPanel(){
		super();
		Model.addModelChangeListener(modelChange);
		add(predictedClass);
	}
}
